<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class UserValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'username|用户名' => 'require|min:5|max:30|chsDash',
        'email|邮箱' => 'require|email',
        'password|密码' => 'require|min:5|max:30|chsDash',
        'is_admin|用户权限' => 'require|in:0,1'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [];

    protected $scene = [
        'addAdmin' => ['username','email','password','is_admin'],
        'setAdmin' => ['username','email','password','is_admin']
    ];
}
